//package com.haoze.nurseapp.schedule;
//
//import com.haoze.common.utils.DateUtil;
//import com.haoze.nurseapp.dao.OrdersFileIndexDataMapper;
//import com.haoze.nurseapp.dao.StaticCenterMapper;
//import com.haoze.nurseapp.dao.TaskExecuteMapper;
//import com.haoze.common.model.OrdersFileIndexDataEntity;
//import com.haoze.nurseapp.service.NursePatientOrderService;
//import com.haoze.nurseapp.service.feign.PatientOrderService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
//@Component
//@ConditionalOnProperty(prefix = "schedule", name = "staticsync", havingValue = "true")
//public class StaticSyncSchedule {
//
//    private static final Logger logger = LoggerFactory.getLogger(StaticSyncSchedule.class);
//
//    @Resource
//    StaticCenterMapper staticCenterMapper;
//
//    @Resource
//    TaskExecuteMapper taskExecuteMapper;
//
//    @Resource
//    OrdersFileIndexDataMapper nurseFileIndexDataMapper;
//
//    @Resource
//    NursePatientOrderService patientOrderService;
//
//
//    /**
//     * 每10秒同步一下数据
//     */
//    @Scheduled(cron = "0/10 * * * * ?")
//    @Deprecated
//    public void staticSync() {
//
//        // 查询所有静配类型医嘱
//        String endTime = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
//        String beginTime = DateUtil.dateToString(DateUtil.getTargetDate(new Date(), 0,0,0,0,0,-20), "yyyy-MM-dd HH:mm:ss");
//
//        logger.info("staticSync : {} ; {}" ,beginTime,endTime);
//
//        List<Map<String, String>> list = staticCenterMapper.queryAllStaticOrders(beginTime, endTime);
//        list.stream().forEach(map -> {
//            String endStr = map.get("qrCode").substring(map.get("qrCode").length()-2, map.get("qrCode").length());
//            String status = "未加药";
//            String dataCode = "e08165457f3442beaf5a5674daabf6f3";
//            if ("_1".equals(endStr)) { // 加药
//                status = "已加药";
//                dataCode = "61224789ffe9413fb84c981f14ec13ad";
//
//                OrdersFileIndexDataEntity fileIndexDataEntity = taskExecuteMapper.queryFileIndexData(map.get("taskExecuteDetailId"));
//                fileIndexDataEntity.setDataValue(status);
//                fileIndexDataEntity.setDataCode(dataCode);
//                nurseFileIndexDataMapper.updateByPrimaryKeySelective(fileIndexDataEntity);
//            }
//            taskExecuteMapper.updateBarCodeByQrCode(map.get("taskExecuteId"));
//            logger.info("endStr = {}", endStr);
//            logger.info("detailId = {}", map.get("taskExecuteDetailId"));
//            String userId = "bf533ba10ec64ab0bbf360c44fa7a787";
//            patientOrderService.createNextTaskNode(map.get("taskExecuteDetailId"),Integer.valueOf(map.get("BATCH_NO")), userId, "", "", "","");
//        });
//
//        // 将所有静配类型医嘱任务qrCode设置为barCode
//    }
//
//}
